package com.gxa.hualianeshop.common.base;

import lombok.Data;

import java.io.Serializable;

/**
 * 通用的返回给前端的状态信息的工具类, 本身不需要注册bean
 * @author bill
 * @date 2023/6/2 16:37
 */
@Data
public class R implements Serializable {
    private String code;
    private String msg;
    private Object data;

    public R(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public R() {
    }

    public R(Object data) {
        this.code = "200";
        this.msg = "success";
        this.data = data;
    }

    public static R ok(){
        return new R("200","success");
    }

    public static R ok(Object data){
        return new R(data);
    }

    public static R failed(){
        return new R("500","faild");
    }
    public static R failed(String message){
        return new R("500",message);
    }

}
